package com.ringtheweb.model.notification;

import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.ringtheweb.model.User;

@Entity
@Table(name="REGISTRATION_QUERY_NOTIFICATION")
@DiscriminatorValue("REGISTRATION_QUERY")
@NamedQueries({
	@NamedQuery(name="findFailedWithMaxCountsForUser",query="select n from RegistrationQueryNotification n where n.status=false" +
			" and n.historyLines.size<:maxCount and n.userToRegister.status.type=:type")
})
public class RegistrationQueryNotification extends Notification {
	
	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = 1L;
	
	@ManyToOne
	@JoinColumn(name="USER_ID",unique=true)
	@Fetch(FetchMode.JOIN)
	private User userToRegister;
	
	private RegistrationQueryNotification() {
	}
	
	public RegistrationQueryNotification(User userToRegister) {
		this.userToRegister = userToRegister;
	}

	public User getUserToRegister() {
		return userToRegister;
	}

	public void setToUserToRegister(User toUser) {
		this.userToRegister = toUser;
	}
	

}
